package mobi.hami.huapin.dao;

import mobi.hami.huapin.daobase.CrudMapper;
import mobi.hami.huapin.model.UserInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface UserInfoMapper extends CrudMapper<UserInfo> {

    @Update(value = "update user_info set phone =  #{1} where id = #{0}")
    int updatePhone(Integer id,String phone);

    @Insert("insert into user_info(create_time) values (#{userInfo.create_time})")
    @Options(useGeneratedKeys = true,keyProperty = "userInfo.id",keyColumn = "id")
    void saveUserInfo(@Param("userInfo") UserInfo userInfo);

    @Select("select * from user_info where id = #{id} LIMIT 1")
    UserInfo selectById(@Param("id")Integer id);

    @Select("select id from user_info where phone = #{phone} LIMIT 1")
    String selectOneUserIdBy(@Param("phone") String phone);

}